package com.pzi.blog.controller;

import com.pzi.blog.service.CommentsService;
import com.pzi.blog.vo.Result;
import com.pzi.blog.vo.params.CommentsParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Pzi
 * @create 2022-04-18 0:36
 */
@Slf4j
@RestController
@RequestMapping("/comments")
public class CommentsController {

    @Autowired
    private CommentsService commentsService;

    @GetMapping("/article/{id}")
    public Result comments(@PathVariable("id") Long articleId) {

        log.warn("查询评论开始了");
        return commentsService.selectCommentsByArticleId(articleId);

    }

    @PostMapping("/insert")
    public Result insert(@RequestBody CommentsParam commentsParam){

        return commentsService.insert(commentsParam);
    }


}
